'use client'; // todo mark

import { Platform, View } from "react-native";
import React from "react";
// import { ScreenContainerProps } from "react-native-screens"; // todo del
import { ScreenContainerProps } from "react-native-screens/src/types"; // todo mark
import { isNativePlatformSupported, screensEnabled } from "../core";

// Native components
import ScreenContainerNativeComponent from "../specs/ScreenContainerNativeComponent";
import ScreenNavigationContainerNativeComponent from "../specs/ScreenNavigationContainerNativeComponent";

// todo del
// export const NativeScreenContainer: React.ComponentType<ScreenContainerProps> =
//   Platform.OS !== "web" ? (ScreenContainerNativeComponent as any) : View;
// export const NativeScreenNavigationContainer: React.ComponentType<ScreenContainerProps> =
//   Platform.OS !== "web"
//     ? (ScreenNavigationContainerNativeComponent as any)
//     : View;

function ScreenContainer(props: ScreenContainerProps) {
  const { enabled = screensEnabled(), hasTwoStates, ...rest } = props;

  if (enabled && isNativePlatformSupported) {
    if (hasTwoStates) {
      const ScreenNavigationContainer =
        Platform.OS === "ios"
          // ? NativeScreenNavigationContainer // todo del
          // : NativeScreenContainer; // todo del
          ? ScreenNavigationContainerNativeComponent // todo mark
          : ScreenContainerNativeComponent; // todo mark
      return <ScreenNavigationContainer {...rest} />;
    }
    // return <NativeScreenContainer {...rest} />; // todo del
    return <ScreenContainerNativeComponent {...rest} />; // todo mark
  }
  return <View {...rest} />;
}

export default ScreenContainer;
